﻿using System;
using MichMan.Utilities.Requests;

namespace MichMan.Utilities
{
    /// <summary>
    /// Uniquely identifies the run of the application.
    /// </summary>
    public class ApplicationRunId : CachedValue<Guid>
    {
        public static ApplicationRunId Instance
        {
            get
            {
                return Singleton<ApplicationRunId>.Create(() => new ApplicationRunId());
            }
        }

        private ApplicationRunId()
            : base(CacheManager.Instance.GetCache("ApplicationState"), typeof(ApplicationRunId).FullName)
        {
            DefaultValue = () => Guid.NewGuid();
        }

        /// <summary>
        /// Reset if you need to treat the app like it's been reset.  E.g. - all the data has changed.
        /// </summary>
        public void Reset()
        {
            this.Value = Guid.NewGuid();
        }
    }
}
